#include <algorithm>
#include <cstdio>
#define lowbit(x) (x & (-x))
typedef long long ll;

const int mod = 998244353, N = 20;

int n, f[1 << N], g[1 << N];
ll sum[1 << N], ans;

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("P5369 [PKUSC2018]最大前缀和.in", "r", stdin);
  freopen("P5369 [PKUSC2018]最大前缀和.out", "w", stdout);
#endif
#endif

  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%lld", &sum[1 << i]), f[1 << i] = 1;
  for (int i = 1; i < 1 << n; ++i) sum[i] = sum[i ^ lowbit(i)] + sum[lowbit(i)];
  g[0] = 1;
  for (int i = 1; i < 1 << n; ++i)
    if (sum[i] < 0) {
      for (int j = 0; j < n; ++j)
        if (i >> j & 1) (g[i] += g[i ^ (1 << j)]) %= mod;
    } else {
      for (int j = 0; j < n; ++j)
        if (!(i >> j & 1)) (f[i | (1 << j)] += f[i]) %= mod;
    }
  for (int i = 1; i < 1 << n; ++i)
    (ans += sum[i] % mod * f[i] % mod * g[((1 << n) - 1) ^ i] % mod) %= mod,
        ans = (ans + mod) % mod;
  printf("%lld", ans);
  return 0;
}